<template>
  <el-form ref="form" :model="form" label-width="80px" :disabled="readonly">
    <el-row>
      <el-col :span="12">
        <el-form-item label="功能名称"
          ><el-input v-model="form.System_6_20"></el-input></el-form-item
      ></el-col>
      <el-col :span="12">
        <el-form-item label="序号">
          <el-input v-model="form.System_6_80"></el-input></el-form-item
      ></el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="地址">
          <el-input v-model="form.System_6_40"></el-input
        ></el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="上级功能">
          <mei-select-tree
            v-model="form.System_6_70"
            width="100%"
            :data="treeData"
            idKey="System_6_10"
            pIdKey="System_6_70"
            nameKey="System_6_20"
          ></mei-select-tree>
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item style="text-align:center" label-width="0">
      <el-button @click="onSave" v-btnper="'sys6save'" type="primary"
        >保存</el-button
      >
      <el-button @click="setDisabled()" v-btnper="'sys6close'">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { System6 } from "@/api";
import Tree from "./Tree";
export default {
  data() {
    return {
      form: this.data,
      treeData: [],
      readonly: true
    };
  },
  async mounted() {
    this.treeData = await System6.get();
  },
  methods: {
    setDisabled(b = "1") {
      this.readonly = b == "1";
    },
    async onSave() {
      let res = await System6.Save(this.form);
      res.strMS && this.$message(res.strMS);
      this.$emit("onSave", res, this.form);
    }
  },
  props: {
    data: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  computed: {},
  components: {},
  watch: {
    data(val) {
      this.form = val;
    },
    "form.System_6_70": {
      handler(newName, oldName) {},
      immediate: true
    }
  }
};
</script>

<style></style>
